package com.qishenyuan.competition.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qishenyuan.competition.annotation.TokenParam;
import com.qishenyuan.competition.common.PageResult;
import com.qishenyuan.competition.common.PageUtil;
import com.qishenyuan.competition.common.Response;
import com.qishenyuan.competition.dto.TeamupReq;
import com.qishenyuan.competition.service.TeamupService;
import com.qishenyuan.competition.vo.TeamUpBriefResp;
import com.qishenyuan.competition.vo.TeamUpDetailResp;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Map;

/**
 * @author Jacky
 * @since 2025-03-03
 */
@RestController
@RequestMapping("/teamUp")
public class TeamUpController {

    @Resource
    private TeamupService teamupService;

    /**
     * 分页获取组队列表
     */
    @RequestMapping("/getTeamUpList")
    public Response<? extends Map> getTeamUpList(@TokenParam String token, @RequestBody @Valid TeamupReq teamupReq){
        IPage<TeamUpBriefResp> teamUpList = teamupService.getTeamupList(token, teamupReq);
        PageResult<TeamUpBriefResp> pageResult = PageUtil.toPageResult(teamUpList);
        return Response.ok(pageResult);
    }

    @GetMapping("/getTeamUpDetail/{id}")
    public Response<TeamUpDetailResp> getTeamUpDetail(@PathVariable Integer id){
        TeamUpDetailResp teamUpDetail = teamupService.getTeamUpDetail(id);
        return Response.ok(teamUpDetail);
    }
}
